
#include <assert.h>
#include "app_platform/cmd_obj.h"
#include "app_platform/cmd_obj_ext.h"
#include "app_platform/cntl_info.h"
#include "app_platform/intf_service_control.h"
#include "storageao_adaptor.h"
#include "storageao_req_resp.h"


std::string g_sstorageaoStandAlone;

///////////////////////
// class CStorageAoSvcFactory
int CStorageAoSvcFactory::init(void* pvParam)
{
	IUserDefineCntl* pCntl = reinterpret_cast<IUserDefineCntl*>(pvParam);
	assert(pCntl);
    pCntl->getConfig("StandAlone", g_sstorageaoStandAlone);
         

	return CStorageAo::Initialize(pCntl);
}

int CStorageAoSvcFactory::CXYZTimerHandler::OnTimer(int iTimerId)
{
    assert(0);
	return 0;
}

int CStorageAoSvcFactory::fini(void* pvParam)
{
    return 0;
}

uint32_t CStorageAoSvcFactory::getCateId() const
{   
	//方法已废弃
    return 0;
}

IService* CStorageAoSvcFactory::createService(uint32_t dwcmdId)
{
    return (new CStorageAoService(dwcmdId));
}

void CStorageAoSvcFactory::getServiceType(ServiceTypeMap_T& mapSvcType)
{
	mapSvcType[STORAGEAO_ADDDISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_ADDLOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_ADDSTOCK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_ADDSTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_DELETEDISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_DELETELOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_DELETESTOCK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_DELETESTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETDISASSEMBLEBILLBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETDISASSEMBLEBILLLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETLOSEBILLOROVERFLOWBILLBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETLOSEBILLOROVERFLOWBILLLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETSTOCKBRANCH_RELBYSYSNO_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETSTOCKBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETSTOCKCHECKBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETSTOCKCHECKLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_GETSTOCKLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_MODIFYSTOCKBRANCH_REL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_UPDATADISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_UPDATALOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_UPDATASTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEAO_UPDATESTOCK_REQ_CMD_ID] = true;
}

////////////////////////
// class CStorageAoService
CStorageAoService::CStorageAoService(uint32_t dwcmdId) 
: m_dwcmdId(dwcmdId)
{
    enum DeployMethod method = DEPLOY_DETACH;
    if(!g_sstorageaoStandAlone.empty() && g_sstorageaoStandAlone != "0") // Stand-Alone
        method = DEPLOY_STANDALONE;
        
    m_pSvc = new CStorageAo(method);
}

void CStorageAoService::Reset() 
{ 
	m_pSvc -> Reset();
}
    
void CStorageAoService::getCmdIdRange(uint32_t& dwcmdIdBegin, uint32_t& dwcmdIdEnd) const 
{ 
    dwcmdIdBegin = m_dwcmdId;
    dwcmdIdEnd = m_dwcmdId;
} 
	
int CStorageAoService::Execute(CCmdObj& oCmd)
{
	switch(oCmd.getCmdId())
	{
	case STORAGEAO_ADDDISASSEMBLEBILL_REQ_CMD_ID:
        return AddDisassembleBill(oCmd);
	case STORAGEAO_ADDLOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return AddLoseBillOrOverFlowBill(oCmd);
	case STORAGEAO_ADDSTOCK_REQ_CMD_ID:
        return AddStock(oCmd);
	case STORAGEAO_ADDSTOCKCHECK_REQ_CMD_ID:
        return AddStockCheck(oCmd);
	case STORAGEAO_DELETEDISASSEMBLEBILL_REQ_CMD_ID:
        return DeleteDisassembleBill(oCmd);
	case STORAGEAO_DELETELOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return DeleteLoseBillOrOverFlowBill(oCmd);
	case STORAGEAO_DELETESTOCK_REQ_CMD_ID:
        return DeleteStock(oCmd);
	case STORAGEAO_DELETESTOCKCHECK_REQ_CMD_ID:
        return DeleteStockCheck(oCmd);
	case STORAGEAO_GETDISASSEMBLEBILLBYSYSNOS_REQ_CMD_ID:
        return GetDisassembleBillBySysNos(oCmd);
	case STORAGEAO_GETDISASSEMBLEBILLLIST_REQ_CMD_ID:
        return GetDisassembleBillList(oCmd);
	case STORAGEAO_GETLOSEBILLOROVERFLOWBILLBYSYSNOS_REQ_CMD_ID:
        return GetLoseBillOrOverFlowBillBySysNos(oCmd);
	case STORAGEAO_GETLOSEBILLOROVERFLOWBILLLIST_REQ_CMD_ID:
        return GetLoseBillOrOverFlowBillList(oCmd);
	case STORAGEAO_GETSTOCKBRANCH_RELBYSYSNO_REQ_CMD_ID:
        return GetStockBranch_RelBySysNo(oCmd);
	case STORAGEAO_GETSTOCKBYSYSNOS_REQ_CMD_ID:
        return GetStockBySysNos(oCmd);
	case STORAGEAO_GETSTOCKCHECKBYSYSNOS_REQ_CMD_ID:
        return GetStockCheckBySysNos(oCmd);
	case STORAGEAO_GETSTOCKCHECKLIST_REQ_CMD_ID:
        return GetStockCheckList(oCmd);
	case STORAGEAO_GETSTOCKLIST_REQ_CMD_ID:
        return GetStockList(oCmd);
	case STORAGEAO_MODIFYSTOCKBRANCH_REL_REQ_CMD_ID:
        return ModifyStockBranch_Rel(oCmd);
	case STORAGEAO_UPDATADISASSEMBLEBILL_REQ_CMD_ID:
        return UpdataDisassembleBill(oCmd);
	case STORAGEAO_UPDATALOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return UpdataLoseBillOrOverFlowBill(oCmd);
	case STORAGEAO_UPDATASTOCKCHECK_REQ_CMD_ID:
        return UpdataStockCheck(oCmd);
	case STORAGEAO_UPDATESTOCK_REQ_CMD_ID:
        return UpdateStock(oCmd);
	default:
		assert(0);
	}
	return 0;
}

int CStorageAoService::AddDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoAddDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoAddDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->AddDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassembleBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.DisassembleBillSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.DisassembleBillSysNo = oReq.DisassembleBillSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::AddLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoAddLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoAddLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->AddLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.LoseBillInfo,
		oReq.OverFlowBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.OverFlowBillSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.OverFlowBillSysNo = oReq.OverFlowBillSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::AddStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoAddStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoAddStockResp oResp;
	
    oResp.dwResult = m_pSvc->AddStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockSysNo = oReq.StockSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::AddStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoAddStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoAddStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->AddStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockCheckMasterSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockCheckMasterSysNo = oReq.StockCheckMasterSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::DeleteDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoDeleteDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoDeleteDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassemblebillSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::DeleteLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoDeleteLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoDeleteLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.FLoseBillSysNo,
		oReq.FOverFlowBillSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::DeleteStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoDeleteStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoDeleteStockResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.FStockSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::DeleteStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoDeleteStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoDeleteStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetDisassembleBillBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetDisassembleBillBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetDisassembleBillBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetDisassembleBillBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.DisassembleBillSysnoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.DisassembleBillList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.DisassembleBillList = oReq.DisassembleBillList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetDisassembleBillList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetDisassembleBillListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetDisassembleBillListResp oResp;
	
    oResp.dwResult = m_pSvc->GetDisassembleBillList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.DisassembleBillFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.DisassembleBillList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.DisassembleBillList = oReq.DisassembleBillList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetLoseBillOrOverFlowBillBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetLoseBillOrOverFlowBillBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetLoseBillOrOverFlowBillBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetLoseBillOrOverFlowBillBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.LoseBillSysNoList,
		oReq.OverFlowSysNoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.LoseBillList,
		oReq.OverFlowList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.LoseBillList = oReq.LoseBillList;
	oResp.OverFlowList = oReq.OverFlowList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetLoseBillOrOverFlowBillList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetLoseBillOrOverFlowBillListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetLoseBillOrOverFlowBillListResp oResp;
	
    oResp.dwResult = m_pSvc->GetLoseBillOrOverFlowBillList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.OverFlowBillOrLoseBillFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.LoseBillList,
		oReq.OverFlowList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.LoseBillList = oReq.LoseBillList;
	oResp.OverFlowList = oReq.OverFlowList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetStockBranch_RelBySysNo(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetStockBranch_RelBySysNoReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetStockBranch_RelBySysNoResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockBranch_RelBySysNo(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockBranchList
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockBranchList = oReq.StockBranchList;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetStockBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetStockBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetStockBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockSysnoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.StockList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.StockList = oReq.StockList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetStockCheckBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetStockCheckBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetStockCheckBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockCheckBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockCheckMasterSysNoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.StockCheckList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.StockCheckList = oReq.StockCheckList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetStockCheckList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetStockCheckListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetStockCheckListResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockCheckList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockCheckFilterPo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.StockCheckList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.StockCheckList = oReq.StockCheckList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::GetStockList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoGetStockListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoGetStockListResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.StockList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.StockList = oReq.StockList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::ModifyStockBranch_Rel(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoModifyStockBranch_RelReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoModifyStockBranch_RelResp oResp;
	
    oResp.dwResult = m_pSvc->ModifyStockBranch_Rel(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockSysNo,
		oReq.BranchSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::UpdataDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoUpdataDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoUpdataDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassembleBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::UpdataLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoUpdataLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoUpdataLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.LoseBillInfo,
		oReq.OverFlowBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::UpdataStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoUpdataStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoUpdataStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageAoService::UpdateStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageAoUpdateStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageAoUpdateStockResp oResp;
	
    oResp.dwResult = m_pSvc->UpdateStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


#include "svc_main.h"

IServiceFactory* GetServiceFactory(void)
{
    return CSvcFactorySingleton::Instance();
}
